import Vue from 'vue'
import VueRouter from 'vue-router'
// import login from '@/views/login/LoginView.vue'
// import layout from '@/views/layout/layout.vue'
import store from '@/store'
Vue.use(VueRouter)
if (localStorage.getItem('token')) {
  store.dispatch('getMenuList')
}
const routes = [
  {
    path: '/login',
    name: 'Login',
    component: () => import('@/views/login/LoginView.vue')
    // component: login
  },
  {
    path: '/',
    redirect: '/login'
  },
  {
    path: '/',
    redirect: '/home',
    // import('@/layout/layout.vue'),
    component: () => import('@/views/layout/layout.vue'),
    children: [
      {
        meta: {
          title: '首页'
        },
        path: 'home',
        component: () => import('@/views/home.vue')
      }
    ]
  }

]

const router = new VueRouter({
  routes
})

export default router
